package com.dove.controller;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("user")
public class RedisCacheController {
    @Cacheable(value = "user",key = "#root.methodName+#root.args[0]")
    @GetMapping("findWord/{id}")
    public String findWord(@PathVariable String id) {
        System.out.println("Cacheing");
        HashMap<String, String> words = new HashMap<>();
        words.put("1", "java");
        words.put("2", "redis");
        words.put("3", "cache");
        return words.get(id);
    }
}
